<template>
	<view class="uni-wrap">
		<view class="tabBox">
			<view class="tab" >
				<view style="margin-top: 100rpx;" v-if="list.length < 1">
					<u-empty
						text="暂无数据"
						icon="https://www.zxsl.zxmap.cn/zxch-app/2023/07/21/005b6980c9514d1e8e4a0cee0de018e4.png">
					</u-empty>
				</view>
				<u-swipe-action>
					<u-swipe-action-item
						:options="options"
						@click="delWzjy"
						v-for="(item,index) in list" :key="item.id">
						<view class="swipe-action u-border-top u-border-bottom" @click="gotoPage('/subPackTask/wzuse/detail?id='+item.id+'&userIdentity=管理员')">
							<view class="PhotographerBoxR" style="margin-left: 30rpx;">
								<view class="text-sm text-grey margin-top-xs">物资编号：{{item.code}}</view>
								<view class="text-sm text-grey margin-top-xs">物资管理员：{{item.adminName}}</view>
								<view class="text-sm text-grey margin-top-xs">物资名称：{{item.wzName}}</view>
								<view class="text-sm text-grey margin-top-xs">借用时间：{{item.borrowTime}}</view>
								<view class="text-sm text-grey margin-top-xs" v-if="item.status == 0">归还时间：{{item.backTime}}</view>
								<view class="text-sm text-grey margin-top-xs" style="display: flex;margin-top: 30rpx;">
									<view>
										<u-avatar v-if="item.avatar" size="20" shape="square" :src="item.avatar"></u-avatar>
										<u-avatar
											v-else
											size="20"
											shape="square"
											:text="item.userName.slice(1)"
											:fontSize="item.userName.length > 2?8:12"
											bgColor="#0087FC">
										</u-avatar>
									</view>
									<span style="padding-left: 10rpx;color: #000;font-size: 28rpx;">由{{item.userName}}提交</span>
									<view style="position: absolute;right: 0;margin-right: 48rpx;">
										<text v-if="item.status == 0" style="color: #269B54;font-weight: 26rpx;">已归还</text>
										<text v-if="item.status == 1" style="color: #E6900D;font-weight: 26rpx;">出借中</text>
									</view>
								</view>
							</view>
						</view>
					</u-swipe-action-item>
				</u-swipe-action>
			</view>
		</view>
		
	</view>
</template>

<script>
	import { strFormatMinutes } from '@/utils/format.js'
	import { getDicts } from '@/api/dict.js'
	import { getList,getAdminList,detwz } from '@/api/wzuse.js'
	export default {
		data() {
			return {
				user:{},
				showLength:4,
				pageNum:1,
				list:[],
				amountAll:'',
				range: [],
				adminUsers:[],
				options: [{
					text: '删除'
				}],
			}
		},
		onReady() {
		},
		onReachBottom(){
			this.pageNum += 1
			this.getListData()
		},
		onPullDownRefresh(){
			this.pageNum = 1
			this.list = []
			this.getListData()
			uni.stopPullDownRefresh()
		},
		onLoad(option) {
			this.user = uni.getStorageSync("loginInfo").user
			this.getListData()
		},
		methods: {
			async getListData(){
				let params = {
					pageNum:this.pageNum,
				}
				const { data } = await getAdminList(params);
				if(data.code == 200 && data.rows.length > 0){
					this.list = [...this.list,...data.rows]
				}
			},
			async delWzjy(e){
				const { data } = await detwz(this.list[e.index].id);
				if(data.code == 200){
					this.list.splice(e.index,1)
				}
			}
		}
	}
</script>

<style>
	page{
		background-color: #f6f6f6;
		color: #333333;
	}
</style>
<style>
	.uni-wrap .tabBox {
		transform: translateX(0);
		transition: all .3s ease;
		height: 100vh;
	}
	.submit-button .submit-block  {
		width: 100vw;
	}
	.uni-wrap .tab {
		position: relative;
		width: 100vw;
	}
</style>